package com.gugee.tiktok.data.consumer.challenge.core.service.mapper;

import com.gugee.tiktok.common.model.mysql.Challenge;
import com.gugee.tiktok.common.model.spider.challenge.ChInfo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(componentModel = "spring")
public interface ChallengeMapper {

    @Mapping(target = "userCount", source = "user_count")
    @Mapping(target = "viewCount", source = "view_count")
    @Mapping(target = "isCommerce", source = "is_commerce")
    @Mapping(target = "chaName", source = "cha_name")
    @Mapping(target = "coverPhoto", source = "hashtag_profile")
    @Mapping(target = "shareUrl", expression = "java(getShareUrl(chInfo))")
    Challenge mapper(ChInfo chInfo);

    default String getShareUrl(ChInfo chInfo){
        return chInfo.getShare_info().getShare_url();
    }
}
